﻿using System;
using System.Security.Permissions;
using HarmonyLib;
using JSONClass;
using UnityEngine;

namespace zrgMod;

public partial class Plugin
{
    [HarmonyPrefix, HarmonyPatch(typeof(script.NewLianDan.LianDan.LianDanPanel), nameof(script.NewLianDan.LianDan.LianDanPanel.FinishAddItem))]
    public static void LianDanPanel_FinishAddItem_Prefix(ref int id, ref int lianzhicishu)
    {

        // 玩家拥有天赋【炼金术士】：成丹数量+20%
        if (PlayerEx.HasTianFu(690411)
            && _ItemJsonData.DataDict[id].ItemFlag.Contains(6)
            && _ItemJsonData.DataDict[id].type == 5)
        {
            int extra_lianzhicishu = (int)Mathf.Floor(Convert.ToSingle(lianzhicishu) * 0.2f);
            lianzhicishu += extra_lianzhicishu;
            var avatar = Tools.instance.getPlayer();
            avatar.addItem(id, extra_lianzhicishu, Tools.CreateItemSeid(id));
        }
    }
}
